import { useEffect, useState } from 'react'
import { getChannelsAPI } from '@/apis/article'

// 获取频道列表
const useChannels = () => {
  const [channelsList, setChannelsList] = useState([])

  useEffect(() => {
    // 定义获取下拉框选项列表
    const getChannels = async () => {
      const res = await getChannelsAPI()
      setChannelsList(res.data.channels)
    }
    getChannels()
  }, [])

  return {
    channelsList
  }
}

export { useChannels }